import * as bcrypt from 'bcrypt';

//密码加密
const hashPassword = async (password: string): Promise<string> => {
  //密码加密
  const saltRounds = 10;
  const hashedPassword = await bcrypt.hash(password, saltRounds);
  return hashedPassword;
};

//密码比对
const comparePasswords = async (
  password: string,
  hashedPassword: string,
): Promise<boolean> => {
  //密码比对
  const isMatch = await bcrypt.compare(password, hashedPassword);
  return isMatch;
};

export { hashPassword, comparePasswords };
